package uniandes.cupi2.musiteka.servidor.interfaz;

import javax.swing.JPanel;
import java.awt.Frame;
import java.awt.BorderLayout;
import javax.swing.JDialog;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.GridBagLayout;
import javax.swing.BorderFactory;
import javax.swing.border.TitledBorder;
import java.awt.Font;
import java.awt.Color;
import java.util.ArrayList;

import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JButton;
import javax.swing.JList;

import uniandes.cupi2.musiteka.servidor.mundo.IMusiteka;
import uniandes.cupi2.musiteka.servidor.mundo.musiteka1.IteradorMusiteka1;
import uniandes.cupi2.musiteka.servidor.mundo.musiteka1.Musiteka;

public class DialogoGeneroPopular extends JDialog
{

    private static final long serialVersionUID = 1L;
    private JPanel jContentPane = null;
    private JPanel jPanelBotones = null;
    private JButton jButtonActualizar = null;
    private JButton jButtonCancelar = null;
	private JScrollPane jScrollPaneGenerosPopularidad = null;
	private JList jListGenerosPopularidad = null;
	public Musiteka mundo=null;
	public DialogoGeneroPopular(IMusiteka nMundo)
	{
		mundo=(Musiteka) nMundo;
		super.setVisible(true);
		initialize();
	}
   
    /**
     * This method initializes this
     * 
     * @return void
     */
    private void initialize( )
    {
        this.setSize(320, 395);
        this.setTitle("Generos por popularidad");
        this.setContentPane( getJContentPane( ) );
    }
    /**
     * This method initializes jContentPane
     * 
     * @return javax.swing.JPanel
     */
    private JPanel getJContentPane( )
    {
        if( jContentPane == null )
        {
            jContentPane = new JPanel( );
            jContentPane.setLayout(null);
            jContentPane.add(getJPanelBotones(), null);
            jContentPane.add(getJScrollPaneGenerosPopularidad(), null);
        }
        return jContentPane;
    }
    /**
     * This method initializes jPanelBotones	
     * 	
     * @return javax.swing.JPanel	
     */
    private JPanel getJPanelBotones( )
    {
        if( jPanelBotones == null )
        {
            jPanelBotones = new JPanel( );
            jPanelBotones.setLayout(null);
            jPanelBotones.setBounds(new Rectangle(15, 285, 286, 61));
            jPanelBotones.setBorder(BorderFactory.createTitledBorder(null, "", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), new Color(51, 51, 51)));
            jPanelBotones.add(getJButtonActualizar(), null);
            jPanelBotones.add(getJButtonCancelar(), null);
        }
        return jPanelBotones;
    }
    /**
     * This method initializes jButtonActualizar	
     * 	
     * @return javax.swing.JButton	
     */
    private JButton getJButtonActualizar( )
    {
        if( jButtonActualizar == null )
        {
            jButtonActualizar = new JButton( );
            jButtonActualizar.setBounds(new Rectangle(30, 15, 106, 31));
            jButtonActualizar.setText("Actualizar");
            jButtonActualizar.addActionListener(new java.awt.event.ActionListener() {
            	public void actionPerformed(java.awt.event.ActionEvent e) 
            	{
            		ArrayList lista=new ArrayList();
            		
            		IteradorMusiteka1 aux = (IteradorMusiteka1) mundo.darGenerosPorPopularidad();
            		while(aux.haySiguiente())
            		{
            			lista.add(aux.darSiguiente());
            		}
            		jListGenerosPopularidad.setListData(lista.toArray());            		
            	
           
        }
        });
		}
        return jButtonActualizar;
    }
    /**
     * This method initializes jButtonCancelar	
     * 	
     * @return javax.swing.JButton	
     */
    private JButton getJButtonCancelar( )
    {
        if( jButtonCancelar == null )
        {
            jButtonCancelar = new JButton( );
            jButtonCancelar.setBounds(new Rectangle(150, 15, 106, 31));
            jButtonCancelar.setText("Cancelar");
            jButtonCancelar.addActionListener(new java.awt.event.ActionListener() {
            	public void actionPerformed(java.awt.event.ActionEvent e) {
            		dispose();
            		System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
            	}
            });
        }
        return jButtonCancelar;
    }
	/**
	 * This method initializes jScrollPaneGenerosPopularidad	
	 * 	
	 * @return javax.swing.JScrollPane	
	 */
	private JScrollPane getJScrollPaneGenerosPopularidad() {
		if (jScrollPaneGenerosPopularidad == null) {
			jScrollPaneGenerosPopularidad = new JScrollPane();
			jScrollPaneGenerosPopularidad.setBounds(new Rectangle(15, 15, 286, 256));
			jScrollPaneGenerosPopularidad.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
			jScrollPaneGenerosPopularidad.setViewportView(getJListGenerosPopularidad());
			jScrollPaneGenerosPopularidad.setBorder(BorderFactory.createTitledBorder(null, "Generos", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), new Color(51, 51, 51)));
		}
		return jScrollPaneGenerosPopularidad;
	}
	/**
	 * This method initializes jListGenerosPopularidad	
	 * 	
	 * @return javax.swing.JList	
	 */
	private JList getJListGenerosPopularidad() {
		if (jListGenerosPopularidad == null) {
			jListGenerosPopularidad = new JList();
		}
		return jListGenerosPopularidad;
	}

}  //  @jve:decl-index=0:visual-constraint="10,10"
